package com.ruoyi.web.controller.moon;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.moon.domain.MoonLeaveMessage;
import com.ruoyi.moon.service.IMoonLeaveMessageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 留言反馈Controller
 * 
 * @author ruoyi
 * @date 2024-12-16
 */
@RestController
@RequestMapping("/moon/message")
public class MoonLeaveMessageController extends BaseController
{
    @Autowired
    private IMoonLeaveMessageService moonLeaveMessageService;

    /**
     * 查询留言反馈列表
     */
    @PreAuthorize("@ss.hasPermi('moon:message:list')")
    @GetMapping("/list")
    public TableDataInfo list(MoonLeaveMessage moonLeaveMessage)
    {
        startPage();
        List<MoonLeaveMessage> list = moonLeaveMessageService.selectMoonLeaveMessageList(moonLeaveMessage);
        return getDataTable(list);
    }

    /**
     * 导出留言反馈列表
     */
    @PreAuthorize("@ss.hasPermi('moon:message:export')")
    @Log(title = "留言反馈", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MoonLeaveMessage moonLeaveMessage)
    {
        List<MoonLeaveMessage> list = moonLeaveMessageService.selectMoonLeaveMessageList(moonLeaveMessage);
        ExcelUtil<MoonLeaveMessage> util = new ExcelUtil<MoonLeaveMessage>(MoonLeaveMessage.class);
        util.exportExcel(response, list, "留言反馈数据");
    }

    /**
     * 获取留言反馈详细信息
     */
    @PreAuthorize("@ss.hasPermi('moon:message:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(moonLeaveMessageService.selectMoonLeaveMessageById(id));
    }

    /**
     * 新增留言反馈
     */
    @PreAuthorize("@ss.hasPermi('moon:message:add')")
    @Log(title = "留言反馈", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MoonLeaveMessage moonLeaveMessage)
    {
        return toAjax(moonLeaveMessageService.insertMoonLeaveMessage(moonLeaveMessage));
    }

    /**
     * 修改留言反馈
     */
    @PreAuthorize("@ss.hasPermi('moon:message:edit')")
    @Log(title = "留言反馈", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MoonLeaveMessage moonLeaveMessage)
    {
        return toAjax(moonLeaveMessageService.updateMoonLeaveMessage(moonLeaveMessage));
    }

    /**
     * 删除留言反馈
     */
    @PreAuthorize("@ss.hasPermi('moon:message:remove')")
    @Log(title = "留言反馈", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(moonLeaveMessageService.deleteMoonLeaveMessageByIds(ids));
    }
}
